package jtk.project4.fleet.screen.addNewFuelTank;

import java.sql.SQLException;

import jtk.project4.fleet.FleetModel;
import jtk.project4.fleet.domain.FuelTank;
import jtk.project4.fleet.domain.Vendor;
import jtk.project4.fleet.event.AddNewFuelTankEvent;
import jtk.project4.fleet.event.VendorEvent;
import jtk.project4.fleet.screen.generalTankInformation.GeneralTankInformationView;
import jtk.project4.fleet.task.LoadVendorTask;
import nl.coderight.jazz.Controller;

public class AddNewFuelTankController extends Controller 
{
	
	private AddNewFuelTankView addNewFuelTankView;
	private FleetModel	fleetModel;
	
	public void handleEvent(AddNewFuelTankEvent evt) throws SQLException {
		FuelTank fuelTank = fleetModel.getFuelTank();
		switch (evt.getType()) {
		case SAVE:
			//commit changes
			fleetModel.insertFuelTank(fuelTank);
			//executeTask(new LoadVendorTask());
			break;
			
		default:
			propagateEvent(evt);
			break;
		}
	}
	public void execute() 
	{
		fleetModel = (FleetModel) getModel();
		addNewFuelTankView = new AddNewFuelTankView();
		setView(addNewFuelTankView);
		showView();
	}
	
	
}

